// hyb_yl/krecovery/pages/order_list/order_list.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLoading:false,
    status: 0,
    tablist: ['全部', '待支付','已支付', '已结束'],
    page:0,
    statuss:"",
    list:[],
    zid:"",
  },
  choose_tab: function (e) {
    var index = e.currentTarget.dataset.index;
    this.setData({
      status: index,
      statuss:index-1,
      page:0,
      list:[],
      isLoading:true,
    })
    this.getOrder();
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var zid = options.zid;
    that.setData({
      zid:zid
    })
    that.getOrder();
    app.util.request({
      'url': 'entry/wxapp/index.base',
      success: function (res) {
        var se = res.data.ztcolor
        wx.setNavigationBarColor({
          frontColor: '#ffffff',
          backgroundColor: se,
        })
      },
      fail: function (err) {
        console.log(err)
      },
    })
  },
  // 确认收货
  toreceive:function(e){
    var that = this;
    var id = e.currentTarget.dataset.id;
    app.util.reqest({
      'url':"entry/wxapp/follow.receive",
      data:{
        id:id
      },
      success:function(res)
      {
        that.setData({
          page:0,
          list:[]
        })
        that.getOrder();
      }
    })
  },
  getOrder: function () {
    var that = this;
    app.util.request({
      'url': "entry/wxapp/follow.zhuanjia_fuwuorder",
      data: {
        zid: that.data.zid,
        page: that.data.page,
        status: that.data.status
      },
      success: function (res) {
        var page = that.data.page + 1;
        that.setData({
          page: page,
          list: that.data.list.concat(res.data),
          isLoading:false
        })
      }
    })
  },
  // 跳转详情 
  todetails:function(e){
    var that = this;
    var back_orser = e.currentTarget.dataset.back_orser;
    var j_id = e.currentTarget.dataset.j_id;
    wx.navigateTo({
      url: '/hyb_yl/doctorHome/pages/acceptpatient/acceptpatient?id='+e.currentTarget.dataset.f_id+'&typs=order&back_orser='+back_orser+'&j_id='+j_id+'&zid='+that.data.zid,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.getOrder();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})